package com.sdkj.recruit.provider;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.ext.ParamConverter;

import org.springframework.stereotype.Component;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Component
public class ListConverter<T> implements ParamConverter<List<T>> {

	@Override
	public List<T> fromString(String value) {
		
		if (value == null) {
			return null;
		} 
		JSONArray array =JSONArray.fromObject(value);
		List<T> list = new ArrayList<T>();
		for(int i=0;i <array.size();i++){
			list.add((T)array.get(i));
		}
		return null;
	}

	@Override
	public String toString(List<T> value) {
		if (value == null) {
			return null;
		}
		return "" + JSONObject.fromObject(value);
	}

	

}
